@extends('layout')
@section('content')
<style> 
.modal-header-danger {
  color:#fff;
    padding:9px 15px;
    border-bottom:1px solid #eee;
    background-color:   #e30022;
    -webkit-border-top-left-radius: 5px;
    -webkit-border-top-right-radius: 5px;
    -moz-border-radius-topleft: 5px;
    -moz-border-radius-topright: 5px;
     border-top-left-radius: 5px;
     border-top-right-radius: 5px;
}

</style>
<div class="panel panel-danger">
      <div class="panel-heading">
      <h3><left><a href = "#"><a class="glyphicon glyphicon-tint text-danger"></a></left>Agregar Nuevo Tipo Insumo</h3>
      </div>
    </div>
        <div class="input-group"> <span class="input-group-addon "><span class="glyphicon glyphicon-search"></span> Buscar</span>
        <input name="filter" id="filter" type="text" class="form-control" placeholder="¿Qué desea buscar?"></div>

        <div class="panel-body">
            <table id="tipos_insumos" class="table table-striped table-hover display" >
                <thead>
                    <tr>
                        <th>ID</th>
                        <th>TIPO</th>
                        <th>ACTIVO</th>
                    </tr>
                </thead>
                <tbody class="searchable">
                    @foreach($tipos_insumos as $tipos_insumos)
                        <tr>
                            <td>{{ $tipos_insumos->id }}</td>
                            <td>{{ $tipos_insumos->tipo }}</td>
                            <td>{{ $tipos_insumos->activo  == 1 ? 'Activo' : 'Inactivo' }}</td>
                            <td>

                     <div class="btn-group">
                     <a href="{{route('tipos_insumos.show', $tipos_insumos->id )}}" data-target="#mostrar" data-toggle="modal" class="btn btn-danger">Ver</a>
                    <a href="#" class="btn btn-danger dropdown-toggle" data-toggle="dropdown"><span class="caret"></span></a>
                    <ul class="dropdown-menu">
                    <li><a href="{{route('tipos_insumos.edit', $tipos_insumos->id )}}" data-target="#editar" data-toggle="modal">Editar</a></li>
                   <li>{{ Form::open(array('url' => 'tipos_insumos/'.$tipos_insumos->id, 'method'=> 'delete')) }}
                      {{ Form::submit('Eliminar',  array('class' => "btn btn-default"))}}
                      {{ Form::close() }}</li>
                    </ul>
                </div>           
                            </td>
                        </tr>
                    @endforeach
                </tbody>
            </table>
            <button class="btn btn-primary" data-toggle="modal" data-target="#crear"><span class="glyphicon glyphicon-plus"></span> Agregar Tipo de Insumo</button>
        </div>
    </div>
@stop
@section('modal')
    @if(Session::has('message'))
        
        <div class="alert alert-{{ Session::get('class') }}"><span class="glyphicon glyphicon-ok-sign"></span>{{ Session::get('message')}}</div>
    @endif
    <div class="modal fade" id="crear" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header modal-header-danger">
        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
        <h1><i class="glyphicon glyphicon-check"></i> Crear Tipo Insumo</h1>
      </div>
        <div class="modal-body">
        {{Form::open(array('url' => 'tipos_insumos', 'method' => 'post'))}}
        <p>{{Form::text('tipo', null, array('class' => 'form-control', 'placeholder' => 'Tipo de Insumo', 'required' => 'required'))}}</p>
        <p><label for="activo">Estado:</label><select name="activo" id="activo" class="form-control">
          <option value="0">Inactivo</option>
            <option value="1">Activo</option>
            </select>
        </p>
      </div>
      <div class="modal-footer">
        <button type="submit" class="btn btn-warning" style="width: 30%"><span class="glyphicon glyphicon-ok-sign"></span> Crear</button>
                <button type="button" class="btn btn-default" style="width: 30%" data-dismiss="modal"><span ></span> Regresar</button>
        </form>
      </div>
    </div>
  </div>
</div>
 <!--Fin Modal crear -->
 <!--Modal editar -->
<div class="modal fade" id="editar" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header modal-header-danger">
        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
        <h1><i class="glyphicon glyphicon-pencil"></i>  Editar Tipo de Insumo</h1>
      </div>
        <div class="modal-body">
             
      </div>
      <div class="modal-footer">
        <input type="submit" value="Guardar" class="btn btn-success"><button class="btn btn-default" data-dismiss="modal">Regresar</button>
        </form>
      </div>
    </div>
  </div>
</div>
 <!--Fin Modal editar -->
 <!--Modal mostrar -->
<div class="modal fade" id="mostrar" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header modal-header-danger">
        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
        <h1><i class="glyphicon glyphicon-list-alt"></i> Insumo</h1>
      </div>
        <div class="modal-body">
             
      </div>
      <div class="modal-footer">
        <input type="submit" value="Guardar" class="btn btn-success"><button class="btn btn-default" data-dismiss="modal">Regresar</button>
        </form>
      </div>
    </div>
  </div>
</div>
 <!--Fin Modal mostrar -->
<script type="text/javascript">
    $(document).ready(function() {
    $('#tipos_insumos').dataTable({
        "dom": 'Rlfrtip',
        "language": {
            "sProcessing":     "Procesando...",
            "sLengthMenu":     "Mostrar _MENU_ registros",
            "sZeroRecords":    "No se encontraron resultados",
            "sEmptyTable":     "Ningún dato disponible en esta tabla",
            "sInfo":           "Mostrando registros del _START_ al _END_ de un total de _TOTAL_ registros",
            "sInfoEmpty":      "Mostrando registros del 0 al 0 de un total de 0 registros",
            "sInfoFiltered":   "(filtrado de un total de _MAX_ registros)",
            "sInfoPostFix":    "",
            "sSearch":         "Buscar:",
            "sUrl":            "",
            "sInfoThousands":  ",",
            "sLoadingRecords": "Cargando...",
            "oPaginate": {
                "sFirst":    "Primero",
                "sLast":     "Último",
                "sNext":     "Siguiente",
                "sPrevious": "Anterior"
                        },
                    }
    } );
    var table = $('#tipos_insumos').DataTable(); 
 
    $('#filter').on( 'keyup', function () {
    table.search( this.value ).draw();
    } );
});
</script>
<script>
   $('#mostrar').on('hidden.bs.modal', function () {
  document.location.reload();
})
   $('#editar').on('hidden.bs.modal', function () {
  document.location.reload();
})  
setTimeout(function() {
    $('#alerta').fadeOut('fast');
}, 2000); // <-- time in milliseconds
</script>
@stop